#pragma once
#include "HashTable.h"


namespace lr
{
	template<class K,class Hash = HashFunc<K>>
	class unordered_set
	{
	public:
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
		typedef typename HashTable<K, K, SetKeyOfT, Hash>::const_iterator iterator;
		typedef typename HashTable<K, K, SetKeyOfT, Hash>::const_iterator const_iterator;
		const_iterator cbegin()
		{
			return _ht.cbegin();
		}

		const_iterator cend()
		{
			return _ht.cend();
		}
		
		pair<iterator,bool> insert(const K& key)
		{
			auto res = _ht.Insert(key);
			return make_pair(iterator(res.first._node, res.first._pht),res.second);
		}


		iterator find(const K& key)
		{
			return _ht.Find(key);
		}
		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		HashTable<K, K, SetKeyOfT,Hash> _ht;
	};

	void Test_set1()
	{
		lr::unordered_set<int> s;
		s.insert(2);
		s.insert(6);
		s.insert(67);
		s.insert(66);
		s.insert(1);
		auto it = s.cbegin();
		while (it != s.cend())
		{
			cout << *it <<" ";
			++it;
		}
		cout << endl;
	}
}




